/*
 * Copyright (C) 2010-2011 Comcast Cable.  All Rights Reserved.
 */
package com.hercules.android.receiver.model.commands;

/**
 * <p>
 * This is a base class for all XRE commands. It holds common properties for all commands: command index and timestamp.
 * All subclasses must implement getCommand() method that returns a constant name of specific command implementation. It
 * is a simple JavaBean (POJO) that provides getters and setters for all private attributes and performs no argument
 * validation in the setters.
 * </p>
 * <p>
 * <strong>Thread safety:</strong> This class is mutable and not thread safe.
 * </p>
 *
 * @author saarixx, jmn
 * @version 1.0
 */
public abstract class XRECommand {
    /**
     * The constant represents the index of local command.
     * <p>
     * Fixed to be -1.
     * <p>
     * AndroidAssembly2 moved form aggregate command handler
     */
    public static final int LOCAL_COMMAND_INDEX = -1;

    /**
     * <p>
     * The index of the command in the current session.
     * </p>
     * <p>
     * Can be any value.
     * </p>
     * <p>
     * Has getter and setter.
     * </p>
     */
    private int commandIndex;

    /**
     * <p>
     * The timestamp of the command.
     * </p>
     * <p>
     * Indicates the time the message was sent, in milliseconds since January 1, 1970.
     * </p>
     * <p>
     * Can be any value. Has getter and setter.
     * </p>
     */
    private double timestamp;

    /**
     * <p>
     * Creates new instance of {@link XRECommand} class.
     * </p>
     */
    protected XRECommand() {
        // empty constructor
    }

    /**
     * <p>
     * Retrieves the name of this command.
     * </p>
     *
     * @return the name of this command
     */
    public abstract String getCommand();

    /**
     * <p>
     * Retrieves the index of the command in the current session.
     * </p>
     *
     * @return the index of the command in the current session
     */
    public int getCommandIndex() {
        return commandIndex;
    }

    /**
     * <p>
     * Sets the index of the command in the current session.
     * </p>
     *
     * @param commandIndex the index of the command in the current session
     */
    public void setCommandIndex(int commandIndex) {
        this.commandIndex = commandIndex;
    }

    /**
     * <p>
     * Retrieves the timestamp of the command.
     * </p>
     *
     * @return the timestamp of the command
     */
    public double getTimestamp() {
        return timestamp;
    }

    /**
     * <p>
     * Sets the timestamp of the command.
     * </p>
     *
     * @param timestamp the timestamp of the command
     */
    public void setTimestamp(double timestamp) {
        this.timestamp = timestamp;
    }
}
